package com.yzl.frelink.util;

import java.io.FileWriter;
import java.util.List;

import org.json.JSONArray;
import org.json.JSONObject;

public class JsonWriter {
    public static void writeJsonFromCsv(String filePath, List<String[]> data) throws Exception {
        JSONArray array = new JSONArray();

        int n = data.size();
        for (int i = 1; i < n; i++) {
            String[] row = data.get(i);
            JSONObject obj = new JSONObject();
            obj.put("id", "req" + i);
            obj.put("content", row[2]);
            obj.put("reqCN", row[0]);
            array.put(obj);
        }

        FileWriter writer = new FileWriter(filePath);
        writer.write(array.toString(4));
        writer.close();
    }
}
